<?php

namespace app\index\model;

use  think\Db;

class DistributionModel
{
    static public function getList($param, $titles = null, $function = null){
        $db = Db::table('distribution_plan');
        !empty($param['code'])&&$db->where('code', 'in',explodeStr($param['code']));
        !empty($param['shop_id_rec'])&&$db->where('shop_id_rec', 'in',explodeStr($param['shop_id_rec']));
        !empty($param['distribution_time'])&&$db->where('distribution_time', $param['distribution_time']);
        $db->order('id','desc');
        return \app\common\service\ToolService::downOrReturn($db, $param, $titles, $function);
    }
    static public function getSKuNum($planIds){
        return DB::table('distribution_plan_detail')
            ->where('distribution_plan_id','in',$planIds)
            ->group('distribution_plan_id')
            ->column("count(sku) as sku_num","distribution_plan_id");
    }
}